import 'package:flutter/foundation.dart';
import 'package:flutter_app/model/recommend_interf.dart';
import 'package:flutter_app/model/user_model.dart';

class ArticleList {
  final List<ArticleItem> list;

  ArticleList(this.list);

  factory ArticleList.fromJson(List<dynamic> list) {
    return ArticleList(list.map((item) => ArticleItem.fromJson(item)).toList());
  }
}

class ArticleItem implements RecommendInterface{
  final int id;
  final int userId;
  final UserItem user;
  final List coverUrlList;
  final String title;
  final int commentCount;
  final int thumbUpCount;
  final int readCount;

  ArticleItem ({
    @required this.id,
    @required this.userId,
    @required this.user,
    @required this.coverUrlList,
    @required this.title,
    @required this.commentCount,
    @required this.thumbUpCount,
    @required this.readCount,
  });

  factory ArticleItem.fromJson(dynamic item) {
    return ArticleItem(
        id: item['id'],
        userId: item['userId'],
        user: UserItem.fromJson(item['user']),
        coverUrlList: item['coverUrlList'],
        title: item['title'],
        commentCount: item['thumbUpCount'],
        thumbUpCount: item['thumbUpCount'],
        readCount: item['readCount']);
  }
}
